package com.feng.sharedingjdbc.rpc;

import com.alibaba.nacos.api.model.v2.Result;
import com.feng.sharedingjdbc.rpc.dto.UserDto;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;

/**
 * @author yinglong.zhang
 * @description
 * @date 2024-1-29 15:10
 */

@FeignClient(name = "seata-user", path = "/user")
public interface UserService {

    @PostMapping("/score")
//    @CircuitBreaker(name = "seata-user", fallbackMethod = "addScoreFallback")
//    Result<Void> addScore(@RequestHeader("TX_XID") String txXid, @RequestBody UserDto userDto);
    Result<Void> addScore(@RequestBody UserDto userDto);

    default Result addScoreFallback(UserDto userDto, Exception exc) {
        return Result.failure("触发熔断");
    }

}
